﻿using System.Collections.Generic;
using ZhaJinHua.Data.Entities;

namespace ZhaJinHua.Data
{
    public class UserService
    {
        private static UserService _instance;
        private Dictionary<string,UserInfo> users = new Dictionary<string, UserInfo>(); 
        public static UserService Instance
        {
            get
            {
                lock (CommonHelper.LockObj)
                {
                    return _instance ?? (_instance = new UserService());
                }
            }
        }
        
        public static void LoadUsers()
        {
            
        }

        public UserInfo Login(string realName)
        {
            lock (CommonHelper.LockObj)
            {
                if (users.ContainsKey(realName))
                {
                    return users[realName];
                }
                var newUser = new UserInfo() { RealName = realName };
                users.Add(realName, newUser);
                return newUser;
            }
        }
    }
}